/* 
 * File:   Utility.h
 * Author: Bram
 *
 * Created on January 10, 2013, 10:43 PM
 */

#ifndef UTILITY_H
#define	UTILITY_H

#include <vector>
#include <iostream>
#include <fstream>
#include <streambuf>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <functional> 
#include <cctype>
#include <locale>
#include <dirent.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

using namespace std;

class Utility
{
private:
	static Utility* instance;
//statusType.erase(std::remove_if(statusType.begin(), statusType.end(), isspace), statusType.end());
public:
	Utility(void);
	~Utility(void);
	static Utility *getInstance()
	{
		if (!instance)
			instance = new Utility;
		return instance;
	}
	vector<string> split(const string &s, char delim);
	vector<string> &split(const string &s, char delim, vector<string> &elems);
	bool startsWith(const string& haystack, const string& needle);
	bool endsWith(const string& haystack, const string& needle);
	bool contains(const string& haystack, const string& needle);
	string convertInt(int number);
        string convertLong(long number);
        const char * const BoolToString(bool b);
        string FullFilePathToFileName(const string& fullFilePath);
        bool FileToPath(string& fullFilePath, bool removeLastSlash);
        void toUpper(string& fullFilePath);
        void toLower(string& fullFilePath);
	bool fileExists(const string& fileName);
        bool directoryExists(const string&);
        bool createDir(const string&, const string&);
        bool isLastFileInFolder(const string&);
        bool isDirectoryEmpty(const string&);
        void removeEmptyFoldersInUpperPath(const string&);
	void getFilesFoldersInDir(const string &path, vector<string> &foundFilesFolders, bool doTimeStamped);
        void getFilesInDirIncludingSubdirs(const string &path, vector<string> &foundFilesFolders, bool doTimeStamped);
        void getFoldersInDirIncludingSubdirs(const string &path, vector<string> &foundFilesFolders);
	string &ltrim(string &s);
	string &rtrim(string &s);
	string &trim(string &s);
        char* Itoa(int value, char* str, int radix);
        void fixPathLinuxWindowsProblem(string& fullPath, bool);
        
        
private:
    void getFilesSubdirsPRIVATE(const string &path, vector<string> &foundFilesFolders, bool doTimeStamped);
    void getFoldersSubdirsPRIVATE(const string &path, vector<string> &foundFilesFolders); //krijgt alle mappen en submappen, NIET de bestanden
};

#endif	/* UTILITY_H */

